<table class="centered small-table">
  <tr>
    <th>nick</th>
    <th>jméno</th>
    <th>email</th>
    <th>posl. login</th>
    <th>registrován od</th>
    <th>role</th>
    <th>akce</th>
  </tr>
  
<?php
	$roles = getConstantsAsArray("ROLE_");
	
    $query = getUzivatele();
    $idx = 0;
    while($fetch = MySQL_Fetch_Array($query)){
      $id = $fetch["ID_UZIVATEL"];
      $nick = $fetch["NICK"];
      $name = $fetch["PRIJMENI"]." ".$fetch["JMENO"];
      $email = $fetch["EMAIL"];
      $reg = $fetch["DATUM_REGISTRACE"];
      $role = $fetch["ROLE"];
      if($role == "") $role = -1;
      $login = $fetch["POSLEDNI_LOGIN"];
      
      if($idx % 2 == 0) { echo "<tr class='second'>"; }
      else echo "<tr>";
        echo "<td class='lefted'>$nick</td>";
        echo "<td class='lefted'>$name</td>";
        echo "<td class='lefted'>$email</td>";
        echo "<td class='lefted'>$login</td>";
        echo "<td class='lefted'>$reg</td>";
        echo "<td class='lefted'>";
        	echo "<form class='nopadding' action=".redirect_str(PAGE_ADMIN_USERS).action(ACTION_CHANGE_ROLE).add_par("a_user_id=".$id)." method='post'>";
        	echo "<select name='a_user_role' class='text nopadding' size=1 width='10' onchange='this.form.submit()'>";
        	if($role == -1) echo "<option value='-1'>bez role</option>";
        	foreach ($roles as $key => $value) {
        		echo "<option value='$value' ".($role==$value?"selected":"").">$key</option>";
        	}
			echo "</select></form>";
		echo "</td>";
		echo "<td class='lefted'><a class='preloader' href=\"".redirect_str(PAGE_ADMIN_USERS).action(ACTION_DELETE_USER).add_par("user_id=".$id)."\"><img class='icon-btn' src='./img/icons/delete.png'></a></td>";
      echo "</tr>";
      $idx ++;
    }
?>
</table>
